package minix.pages;

import java.io.IOException;
import java.io.InputStream;

import org.apache.tapestry5.StreamResponse;
import org.apache.tapestry5.services.Response;

public class InlineStreamResponse implements StreamResponse {
	private InputStream is = null;

	private String contentType = "text/plain";// this is the default

	private String extension = "txt";

	private String filename = "default";

	public InlineStreamResponse() {

	}

	public InlineStreamResponse(InputStream is, String... args) {
		this.is = is;
		if (args != null) {
			this.filename = args[0];
		}
	}

	public String getContentType() {
		return contentType;
	}

	public InputStream getStream() throws IOException {
		return is;
	}

	public void prepareResponse(Response arg0) {
		arg0.setHeader("Content-Disposition", "inline; filename=" + filename
				+ ((extension == null) ? "" : ("." + extension)));
	}

	public InputStream getIs() {
		return is;
	}

	public void setIs(InputStream is) {
		this.is = is;
	}

	public String getExtension() {
		return extension;
	}

	public void setExtension(String extension) {
		this.extension = extension;
	}

	public String getFilename() {
		return filename;
	}

	public void setFilename(String filename) {
		this.filename = filename;
	}

	public void setContentType(String contentType) {
		this.contentType = contentType;
	}
}